<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>websocket</title>
</head>
<body>
<h2>websocket</h2>
<button value="button" onclick="sendMessage();">button</button>
<script type="text/javascript" src="sockjs.js"></script>
<script type="text/javascript" src="webstomp.js"></script>
<script type="text/javascript">
    var socket = new SockJS("/portfolio");
    var stompClient = webstomp.over(socket);

    stompClient.connect({}, function(frame) {
        // console.log(frame);
        stompClient.subscribe("/topic/greeting",function(message){
            console.log("==================")
            console.log(message.body);
        });
    });

    function sendMessage() {
        stompClient.send("/app/greeting","{'greeting':'aaa'}");
        // stompClient.send("/topic/greeting","{'greeting':'aaa'}");
    }
</script>
</body>
</html>